package com.cmb.lk50.config;

/**
 * 解析properties创建对应的bean
 *
 * ImportBeanDefinitionRegistrar
 * BeanDefinitionRegistryPostProcessor
 * //Value("#{'${access-log.sink.chain:console}'.split(',')}")
 *
 */
public class SinkBeanConfig {

}



/*@ConditionalOnProperty(prefix = "access-log", name = "enable", havingValue = "true")
@EnableConfigurationProperties(AccessLogProperties.class)*/


    /*@PostConstruct
    public void init() {
        String[] types = accessLogProperties.getSink().getChain();
        LOGGER.info("读到配置: " + Arrays.toString(types));
        if (types == null || types.length == 0) {
            LOGGER.warn("[AccessLog] - 未指定Sink类型，默认配置Console Sink");
            registerBean(registry, "consoleSink", ConsoleSink.class);
            return;
        }

        Arrays.stream(types)
                .map(String::toLowerCase)
                .forEach(s -> {
                    if ("jdbc".equals(s)) {
                        LOGGER.info("[AccessLog] - 配置JDBC Sink");
                        registerBean(registry, "jdbcSink", JdbcSink.class);

                    } else if ("console".equals(s)) {
                        LOGGER.info("[AccessLog] - 配置Console Sink");
                        registerBean(registry, "consoleSink", ConsoleSink.class);
                    }
                });
    }*/

    /*private ScopeMetadataResolver scopeMetadataResolver = new AnnotationScopeMetadataResolver();
    private BeanNameGenerator beanNameGenerator = new AnnotationBeanNameGenerator();
    private void registerBean(BeanDefinitionRegistry registry, String beanName, Class beanClass) {
        AnnotatedGenericBeanDefinition beanDefinition = new AnnotatedGenericBeanDefinition(beanClass);
        ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(beanDefinition);
        beanDefinition.setScope(scopeMetadata.getScopeName());
        beanName = (beanName != null ? beanName : this.beanNameGenerator.generateBeanName(beanDefinition, registry));

        AnnotationConfigUtils.processCommonDefinitionAnnotations(beanDefinition);
        BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(beanDefinition, beanName);
        BeanDefinitionReaderUtils.registerBeanDefinition(definitionHolder, registry);
    }*/

